package com.bsj.travel.mqtt.cluster;

import lombok.RequiredArgsConstructor;
import net.dreamlu.iot.mqtt.core.server.dispatcher.IMqttMessageDispatcher;
import net.dreamlu.iot.mqtt.core.server.model.Message;
import net.dreamlu.iot.mqtt.core.server.serializer.IMessageSerializer;
import net.dreamlu.mica.redis.stream.RStreamTemplate;

/**
 * @author yinhao
 * @version 1.0
 * @description 消息转发器
 * @date 2023/11/9
 */
//public class MqttMessageDispatcherRedis implements IMqttMessageDispatcher {
//
//    private final RStreamTemplate streamTemplate;
//    private final IMessageSerializer messageSerializer;
//    private final String channel;
//
//    public MqttMessageDispatcherRedis(RStreamTemplate streamTemplate,
//                                      IMessageSerializer messageSerializer,
//                                      String channel) {
//        this.streamTemplate = streamTemplate;
//        this.messageSerializer = messageSerializer;
//        this.channel = channel;
//    }
//
//    @Override
//    public boolean send(Message message) {
//        String topic = message.getTopic();
//        String key = topic == null ? message.getClientId() : topic;
//        streamTemplate.send(channel, key, message, messageSerializer::serialize);
//        return true;
//    }
//}
